package 力扣._318最大单词长度乘积;

import java.util.HashSet;
import java.util.Set;

public class Solution {
    public int maxProduct(String[] words) {
        boolean[][] mask = new boolean[words.length][26];   //每一个单词是否有该字母
        int max = 0;
        //初始化
        for (int i = 0; i < words.length; i++) {
            for (int j = 0; j < words[i].length(); j++) {
                mask[i][words[i].charAt(j) - 'a'] = true;
            }
        }
        for (int i = 0; i < words.length; i++) {
            for (int j = i + 1; j < words.length; j++) {
                boolean b = false;
                for (int k = 0; k < 26; k++) {
                    b = mask[i][k] & mask[j][k];
                    if (b)
                        break;
                }

                if (!b)
                    max = Math.max(max, words[i].length() * words[j].length());
            }
        }
        return max;
    }
}
